import { Asset, Prefab, SpriteFrame, Texture2D, AudioClip, AssetManager, JsonAsset } from 'cc';
import { ResManager } from './ResManager';

export class ResLoader {
    // 加载预制体
    public static async loadBundle(bundleName?: string): Promise<AssetManager.Bundle> {
        return ResManager.instance.loadBundle(bundleName);
    }
    // 加载预制体
    public static async loadPrefab(prefabPath: string, bundleName?: string): Promise<Prefab> {
        return ResManager.instance.load(prefabPath, Prefab, bundleName);
    }

    // 加载图片
    public static async loadSpriteFrame(imagePath: string, bundleName?: string): Promise<SpriteFrame> {
        return ResManager.instance.load(imagePath, SpriteFrame, bundleName);
    }

    // 加载纹理
    public static async loadTexture(texturePath: string, bundleName?: string): Promise<Texture2D> {
        return ResManager.instance.load(texturePath, Texture2D, bundleName);
    }

    // 加载音频
    public static async loadAudio(audioPath: string, bundleName?: string): Promise<AudioClip> {
        return ResManager.instance.load(audioPath, AudioClip, bundleName);
    }

    // 加载json
    public static async loadJson(jsonPath: string, bundleName?: string): Promise<any> {
        return ResManager.instance.load(jsonPath, JsonAsset, bundleName);
    }

    // 释放资源
    public static release(path: string, bundleName?: string): void {
        ResManager.instance.release(path, bundleName);
    }
}
